home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
9-Digit Zip Code Directory
/
9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO
/
z4src.zip
/
BSCTRLC.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-09-10
|
4KB
|
129 lines
//----------------------------------------------------------------------------
// MODULE DESCRIPTION
//
// Module: bsctrlc.c
// Title: Base library
// Notice: John M. Weeder
// Copyright (c) 1993. All rights reserved.
// This module contains proprietary information and should be
// treated as confidential.
//
//----------------------------------------------------------------------------
// MAINTENANCE HISTORY
//
// $Workfile$
// $Revision$
// $Author$
// $Date$
// $Log$
//
//----------------------------------------------------------------------------
// MODULE NARRATIVE
//
//
// This module contains code to disable Ctrl-C, Ctrl-Break and Ctrl-Alt-Del.
//
// The code in this module should be written entirely in C.
// Do not use any C++ constructs.
//
// This module is portable to:
// DOS 3.X+
// MS Windows 3.X+
// OS/2 2.X+
// OS/2 2.0 PM
// SCO UNIX.
//
// The following compilers are supported:
// MSC 6.0A
// MSC/C++ 7.0
// Borland C++ 3.1 for DOS
// Borland C++ 1.0 for OS/2 2.X
// SCO UNIX cc
//
//----------------------------------------------------------------------------
#include <bs.h>
#if OS_DOS && COMPILER_BORLAND
//----------------------------------------------------------------------------
// Globals
//----------------------------------------------------------------------------
static PBYTE pbModifiers = MK_FP(0,0x417);
static void _interrupt (*oldint9)(void);
#define CTRLALT (0x08|0x04)
#define CTRL (0x08)
#define DELSCAN (0x53)
#define CSCAN (0x46)
#define BREAKSCAN (0x70)
#define KEYPORT (0x60)
//----------------------------------------------------------------------------
// Description: New interrupt handler for INT 9 (keboard monitor)
// Parameters:
// Returns:
//----------------------------------------------------------------------------
void _interrupt new_int_9(void)
{
if (((((*pbModifiers) & CTRL) == CTRL)
&& ((inportb(KEYPORT) == BREAKSCAN) || (inportb(KEYPORT) == CSCAN)))
|| ((((*pbModifiers) & CTRLALT) == CTRLALT) && (inportb(KEYPORT) == DELSCAN)))
{
_asm { // Reenable keyboard
IN AL,61h // Read key
MOV AH,AL
OR AL,80h
OUT 61h,AL
XCHG AL,AH
OUT 61h,AL
CLI
MOV AL,20h
OUT 20h,AL
STI
}
}
else // If the key is not CTRL-C or
(*oldint9)(); // CTRL-BREAK, call the old INT 9 handler
}
//----------------------------------------------------------------------------
// Description: Initialize keyboard monitor. Prevent Ctrl-C, Ctrl-Break and
// Ctrl-Alt-Del from breaking out of the program.
// Parameters:
// Returns:
//----------------------------------------------------------------------------
VOID FN_E CtrlCInitialize(void)
{
if (oldint9 == NULL)
{
oldint9 = _dos_getvect(9);
_dos_setvect(9,new_int_9);
BaseExitFunc((PFNEXIT)CtrlCTerminate, SYS_EXIT_PRIORITY);
}
return ;
}
//----------------------------------------------------------------------------
// Description: Reset keyboard monitors
// Parameters:
// Returns:
//----------------------------------------------------------------------------
VOID FN_E CtrlCTerminate(void)
{
if (oldint9)
{
Assert(oldint9 == _dos_getvect(9));
_dos_setvect(9,oldint9);
oldint9 = NULL;
}
return ;
}
//----------------------------------------------------------------------------
//------------------------------- End of File --------------------------------
//----------------------------------------------------------------------------
#endif